<?php
require_once '../init.php';
$fileUploader = new FileUploader();
$file = $fileUploader->getFile($_GET['file_id']);
//var_dump($file->path);
//echo file_exists($file->path);
if($file==null || !file_exists($file->path) || false===strpos($file->type, "image")){
  header("HTTP/1.0 404 Not Found");
}else{
  header("Pragma: public");
  header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
  header("Cache-Control: private",false);
  header("Content-Type: ".$file->type); 
  header("Content-Disposition: attachment; filename=\"".$file->name."\";" ); 
  header("Content-Transfer-Encoding: binary"); 
  header("Content-Length: ".$file->size); 
  ob_clean(); 
  flush(); 
  readfile( $file->path ); 
}

?>
